package com.kefu.chat.vo;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.chat.model.ChatConversationMsg;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author CodeGenerator
 * @date 2022/08/15
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "内部会话消息")
public class ChatConversationMsgSearchVo extends AbstractSearchVo {

    @ApiModelProperty(value = "内部会话id")
    private String conversationId;
    @ApiModelProperty(value = "消息时间开始")
    private Long msgTimeStart;
    @ApiModelProperty(value = "消息时间结束")
    private Long msgTimeEnd;
    @ApiModelProperty(value = "发送者id")
    private String sender;
    @ApiModelProperty(value = "发送者名称")
    private String senderName;
    @ApiModelProperty(value = "消息类型：1.文字，2图片，3富文本，4文件，5音频，6视频")
    private Integer msgType;
    @ApiModelProperty(value = "文件名字")
    private String fileName;
    @ApiModelProperty(value = "音频时长，秒")
    private Integer audioDuration;
    @ApiModelProperty(value = "消息撤回标志 0=无，1=有")
    private Integer recallFlag;
    @ApiModelProperty(value = "消息内容")
    private String msgContent;

	 @Override
    public  LambdaQueryWrapper<ChatConversationMsg> lambdaQuery(){
    	LambdaQueryWrapper<ChatConversationMsg> wrapper=Wrappers.<ChatConversationMsg>lambdaQuery();
	    wrapper.eq(StringUtils.isNotBlank(conversationId), ChatConversationMsg::getConversationId, conversationId);//内部会话id
		wrapper.ge(msgTimeStart!=null, ChatConversationMsg::getMsgTime, msgTimeStart);//消息时间开始
		wrapper.le(msgTimeEnd!=null, ChatConversationMsg::getMsgTime, msgTimeEnd);//消息时间结束
	    wrapper.eq(StringUtils.isNotBlank(sender), ChatConversationMsg::getSender, sender);//发送者id
	    wrapper.eq(StringUtils.isNotBlank(senderName), ChatConversationMsg::getSenderName, senderName);//发送者名称
		wrapper.eq(msgType!=null, ChatConversationMsg::getMsgType, msgType);//消息类型：1.文字，2图片，3富文本，4文件，5音频，6视频
	    wrapper.eq(StringUtils.isNotBlank(fileName), ChatConversationMsg::getFileName, fileName);//文件名字
		wrapper.eq(audioDuration!=null, ChatConversationMsg::getAudioDuration, audioDuration);//音频时长，秒
		wrapper.eq(recallFlag!=null, ChatConversationMsg::getRecallFlag, recallFlag);//消息撤回标志 0=无，1=有
	    wrapper.eq(StringUtils.isNotBlank(msgContent), ChatConversationMsg::getMsgContent, msgContent);//消息内容
	    wrapper.eq(ChatConversationMsg::getTenantId, KefuContext.getKefuContext().getTenantId());
	    
    	return wrapper;
	}
}